<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">
<title>订单详情</title>
<link href="../static/css/admin.css" rel="stylesheet" type="text/css">
<link href="../static/css/amazeui.css" rel="stylesheet" type="text/css">
<link href="../static/css/personal.css" rel="stylesheet" type="text/css">
<link href="../static/css/orstyle.css" rel="stylesheet" type="text/css">
<script src="../static/js/jquery.min.js"></script>
<script src="../static/js/amazeui.js"></script>
<script type="text/javascript" src="/static/js/myinit.js"></script>
</head>

<body>
<!--头 -->
<header>
  <article>
    <div class="mt-logo"> 
      <!--顶部导航条 -->
      <div class="am-container header">
        <ul class="message-l">
          <div class="topMessage">
            <div class="menu-hd"> <a href="#" target="_top" class="h">亲，请登录</a> <a href="#" target="_top">免费注册</a> </div>
          </div>
        </ul>
        <ul class="message-r">
          <div class="topMessage home">
            <div class="menu-hd"><a href="#" target="_top" class="h">商城首页</a></div>
          </div>
          <div class="topMessage my-shangcheng">
            <div class="menu-hd MyShangcheng"><a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
          </div>
          <div class="topMessage mini-cart">
            <div class="menu-hd"><a id="mc-menu-hd" href="#" target="_top"><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
          </div>
             <div class="topMessage favorite">
            <div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
          </div>
        </ul>
      </div>
      
      <!--悬浮搜索框-->
      
      <div class="nav white">
        <div class="logoBig">
          <li><img src="../static/img/logobig.png" /></li>
        </div>
        <div class="search-bar pr"> <a name="index_none_header_sysc" href="#"></a>
          <form>
            <input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
            <input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
          </form>
        </div>
      </div>
      <div class="clear"></div>
    </div>
    </div>
  </article>
</header>
<div class="nav-table">
  <div class="long-title"><span class="all-goods">全部分类</span></div>
  <div class="nav-cont">
    <ul>
      <li class="index"><a href="#">首页</a></li>
      <li class="qc"><a href="#">闪购</a></li>
      <li class="qc"><a href="#">限时抢</a></li>
      <li class="qc"><a href="#">团购</a></li>
      <li class="qc last"><a href="#">大包装</a></li>
    </ul>
    <div class="nav-extra"> <i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的优惠券<i class="am-icon-angle-right" style="padding-left: 10px;"></i> </div>
  </div>
</div>
<b class="line"></b>
<div class="center">
  <div class="col-main">
    <div class="main-wrap">
      <div class="user-orderinfo"> 
        
        <!--标题 -->
        <div class="am-cf am-padding">
          <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">订单详情</strong> / <small>Order&nbsp;details</small></div>
        </div>
        <hr/>
        <!--进度条-->
        <div class="m-progress">
          <div class="m-progress-list"> <span class="step-1 step"> <em class="u-progress-stage-bg"></em> <i class="u-stage-icon-inner">1<em class="bg"></em></i>
            <p class="stage-name">拍下商品</p>
            </span> <span class="step-2 step"> <em class="u-progress-stage-bg"></em> <i class="u-stage-icon-inner">2<em class="bg"></em></i>
            <p class="stage-name">卖家发货</p>
            </span> <span class="step-3 step"> <em class="u-progress-stage-bg"></em> <i class="u-stage-icon-inner">3<em class="bg"></em></i>
            <p class="stage-name">确认收货</p>
            </span> <span class="step-4 step"> <em class="u-progress-stage-bg"></em> <i class="u-stage-icon-inner">4<em class="bg"></em></i>
            <p class="stage-name">交易完成</p>
            </span> <span class="u-progress-placeholder"></span> </div>
          <div class="u-progress-bar total-steps-2">
            <div class="u-progress-bar-inner"></div>
          </div>
        </div>
        <div class="order-infoaside" style="margin: 20px 310px;">
          <div class="order-addresslist" id="adresslist">
          
            
            
          </div>
        </div>
        <div class="order-infomain">
          <div class="order-top">
            <div class="th th-item">
              <td class="td-inner">商品</td>
            </div>
            <div class="th th-price">
              <td class="td-inner">单价</td>
            </div>
            <div class="th th-number">
              <td class="td-inner">数量</td>
            </div>
            <div class="th th-operation">
              <td class="td-inner">商品操作</td>
            </div>
            <div class="th th-amount">
              <td class="td-inner">合计</td>
            </div>
            <div class="th th-status">
              <td class="td-inner">交易状态</td>
            </div>
            <div class="th th-change">
              <td class="td-inner">交易操作</td>
            </div>
          </div>
          <div class="order-main" id="shangpinlist">
          
          
            
            
          </div>
        </div>
      </div>
    </div>
    <!--底部-->
    <div class="footer ">
      <div class="footer-hd">
        <p><img src="../static/img/duo.png" style="width:25px" />品类齐全<b>|</b><img src="../static/img/kuai.png" style="width:25px" />多仓直发<b>|</b><img src="../static/img/hao.png" style="width:25px" />正品行货<b>|</b><img src="../static/img/sheng.png" style="width:25px" />天天低价</p>
      </div>
      <div class="footer-bd "> </div>
    </div>
  </div>
  <aside class="menu">
    <ul>
      <li class="person"> <a href="index_pc.html">个人中心</a> </li>
      <li class="person"> <a href="#">个人资料</a>
        <ul>
          <li> <a href="information.html">个人信息</a></li>
          <li> <a href="safety.html">安全设置</a></li>
          <li> <a href="address.html">收货地址</a></li>
        </ul>
      </li>
      <li class="person"> <a href="#">我的交易</a>
        <ul>
          <li class="active"><a href="order.html">订单管理</a></li>
          <li> <a href="change.html">退款售后</a></li>
        </ul>
      </li>
      <li class="person"> <a href="#">我的资产</a>
        <ul>
          <li> <a href="coupon.html">优惠券 </a></li>
          <li> <a href="bonus.html">充值</a></li>
          <li> <a href="bill.html">账单明细</a></li>
        </ul>
      </li>
      <li class="person"> <a href="#">我的小窝</a>
        <ul>
          <li> <a href="collection.html">收藏</a></li>
          <li> <a href="foot.html">足迹</a></li>
          <li> <a href="comment.html">评价</a></li>
          <li> <a href="news.html">消息</a></li>
        </ul>
      </li>
    </ul>
  </aside>
</div>
<script type="text/javascript">
var oid = getUrldata('ORDERID');
var openid=getUrldata('OPENID');
var pingjia_all={};
$.ajaxSettings.async = false;
$.ajaxSettings.cache=false;

$(document).ready(function(){
	initOrder();
	initlist();
});

function initlist(){
	var url="/webserver/api/v1/orderitem/?format=json&order="+oid;
	$.getJSON(url,function(rs){
		var objects=rs.objects;
		if(objects!=null&&objects!=undefined&&objects.length>0){
			$.each(objects,function(index,item){
				$('#adresslist').append('<div class="order-address"><div class="icon-add"> </div><p class="new-tit new-p-re"> <span class="new-txt">'+item.order.custname+'</span> <span class="new-txt-rd2">'+item.order.phoneno+'</span> </p> <div class="new-mu_l2a new-p-re"><p class="new-mu_l2cw"> <span class="title">收货地址：</span> <span class="street">'+item.order.cityname+item.order.detailAdrinfo+'</span></p></div></div>');
			});
		}
	});
}


function initOrder(){
	var url="/webserver/api/v1/orderitem/?format=json&order="+oid;
	$.getJSON(url,function(rs){
		var object = rs.objects[0];
		var order = object.order;
		$('#orderid').html(order.id);
		
		$('#all_count').html(order.count);
		$('#order_price').html("￥"+order.price);
		var htm="";
		var htm_status=order.status;
		if(order.status=='已下单'){
			htm='<div class="am-btn am-btn-danger anniu" style="background:#4AA5FF;border-color:#4AA5FF">支付</div><div class="am-btn am-btn-danger anniu">取消</div>';
		}else if(order.status=='已取消'){
			htm="";
		}else if(order.status=='已支付'){
			htm="";
		}else if(order.status=='已发货'){
			htm='<div class="am-btn am-btn-danger anniu">确认收货</div>';	
		}else if(order.status=='收货'){
			 
		}else if(order.status=="确认收货"){
			htm_status="已收货";	
		}
		$('#status').html(htm_status);
		$('#shouname').html(order.custname);
		$('#shouhuophone').html(order.phoneno);
	 
		$('#shouhuoaddr').html(order.cityname+order.detailAdrinfo);
		$('#order_action').append(htm);
	 
		var time=order.modified;
		time=time.replace("T"," ");
		$('#time').html(time);
		var status=order.status;
		var goods=object.goods;
		
		
		var cuxiaoid=order.deductionitemid;
		if(cuxiaoid!=null&&cuxiaoid!=0){
			initayouhui(cuxiaoid);
		}

		$.each(rs.objects,function(index,item){
			var pingjia_htm='';
			if(status=='确认收货'){
				pingjia_htm=ispingjia(oid,item.goods.id); 
			}
			$('#shangpinlist').append('<div class="order-status3"><div class="order-title"> <div class="dd-num">订单编号：<a href="javascript:;">'+item.goods.id+'</a></div> </div> <div class="order-content"> <div class="order-left"><ul class="item-list"><li class="td td-item"><div class="item-pic"> <a href="#" class="J_MakePoint"> <img src="'+item.goods.image_thumb+'" class="itempicJ_ItemImg"> </a> </div><div class="item-info"><div class="item-basic-info"> <a href="#"> <p>'+item.goods.name+'</p>'+item.good_format+'</a> </div></div></li> <li class="td td-price"><div class="item-price"> '+item.goods.price+' </div> </li> <li class="td td-number"><div class="item-number"> <span>×</span>'+item.count+' </div></li><li class="td td-operation"> <div class="item-operation"> 退款/退货 </div></li> </ul></div><div class="order-right"> <li class="td td-amount"><div class="item-amount"> 合计：'+item.goods.price*item.count+'元</div></li><div class="move-right"> <li class="td td-status"><div class="item-status"><p class="Mystatus">'+item.order.status+'</p></div></li><li class="td td-change">'+htm+'</li></div></div></div></div>');

			$('#shangpinlist #'+item.goods.id+' button').click(function(){
				if($(this).html()=='评价'){
					document.location.href="pingjia.html?ORDERID="+oid+"&GOODID="+item.goods.id+"&OPENID="+openid;
				} 
			}); 
		});
		$('#order_action button').click(function(){
			if($(this).html()=='支付'){
				//pay(oid);
				var bb=[];
				var aa={};
				aa.NAME="余额支付";
				aa.ACTION=function(){ zhifudialogshow(oid); };
				bb.push(aa);
				aa={};
				aa.NAME="微信支付";
				aa.ACTION=function(){
					pay(oid);
				};
				bb.push(aa);
				toastwithactions("请选择支付方式",bb);
			}else if($(this).html()=='取消'){
				quxiao(oid);
				
			}else if($(this).html()=='确认收货'){
				querenshouhuo(oid);
			}
		});

	});
}
/*
function ispingjia(orderid,spid){
	var oo=pingjia_all[orderid];
	if(oo==undefined){
		var url = "/webserver/api/v1/custassess/?format=json&order="+orderid;
		$.getJSON(url, function(data){
			pingjia_all[orderid]=data;
		});
	}
	oo=pingjia_all[orderid];
	if(oo.objects.length>0){
		var ispijia=false;
		$.each(oo.objects,function(index,item){
			var goodid=item.goods.id;
			if(spid==goodid){
				ispijia=true;
			}
		});
		if(ispijia){
			return "";
		}else{
			return '<div class="my-p2" style="border-top:none"><button class="my-btn1 f-r">评价</button></div>';
		}
		
		
		
	}else{
		return '<div class="my-p2" style="border-top:none"><button class="my-btn1 f-r">评价</button></div>';
	}

}

function pay(oid){
	if(oid!=-1){
		var url="/weixin/getpayparm/";
		$.post(url,{"orderid":oid},function(aa){
			if (typeof WeixinJSBridge == "undefined"){
				if( document.addEventListener ){
					document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
				}else if (document.attachEvent){
					document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
					document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
				}
			}else{
				onBridgeReady(aa);
			}
		}, "json");
	}
}


function onBridgeReady(aa){
	
	 
	WeixinJSBridge.invoke('getBrandWCPayRequest', {
		"appId" : aa.appId,     //公众号名称，由商户传入     
		"timeStamp" : aa.timeStamp+"",         //时间戳，自1970年以来的秒数     
		"nonceStr"  :  aa.nonceStr, //随机串     
		"package"  :  aa.package,
		"signType"  :  aa.signType,         //微信签名方式 : 
		"paySign"  :  aa.paySign //微信签名 
	},
	function(res){     
		if(res.err_msg == "get_brand_wcpay_request:ok" ) {
		 
			toastwithaction('支付成功',function(){
				document.location.reload();
			});
		}
		
	});
}


function querenshouhuo(oid){
	var aa={};
	aa.id=oid;
	aa.status="确认收货";
	var url = "/webserver/api/v1/order/"+oid+"/";
	doput(url,aa,function(rs){
		if(rs.status=="确认收货"){
			toastwithaction("已确认收货",function(){
				document.location.reload();
			});
			
		}
		 
	});
}

function quxiao(oid){
	var aa={};
	aa.id=oid;
	aa.status="已取消";
	var url = "/webserver/api/v1/order/"+oid+"/";
	doput(url,aa,function(rs){
		if(rs.status=="已取消"){
			toastwithaction("已取消",function(){
				document.location.reload();
			});
			
		}
		 
	});
}
function payincash(oid){
	if(oid!=-1){
		var url="/weixin/payorder/";
		$.post(url,{"orderid":oid},function(aa){
			if(aa.code=='true'){
				setTimeout(function(){
					 
				
					toastwithaction("支付成功",function(){
						document.location.reload();
						
					});
					
				
				},500);
				
					
			}else{
				setTimeout(function(){
					var bb=[];
					var aa={};
					aa.NAME="去充值";
					aa.ACTION=function(){ document.location.href="xianjinzhanghu.html?OPENID="+openid;};
					bb.push(aa);
				
					toastwithactions("余额不足!?",bb);

				},500);

			}
		}, "json");
	}
}

function initayouhui(deduid){
	var url="/webserver/api/v1/deduction/?format=json&id="+deduid;
	$.getJSON(url,function(rs){
		var object = rs.objects[0];
		$('#youhui').html(object.name);
		
	
	},'json');
}

	//在支付前判断  如果没有密码先去设置密码 , 如果有的话 弹出的支付密码输入框....

function haspasswordornot(){
	var isok=true;
	var url="/webserver/api/v1/user/?format=json&openid="+openid;
	$.getJSON(url,function(rs){
		var object=rs.objects[0];
	
		var password=object.password;
		if(password==null||password=='null'||password=='undefined'||password==undefined){
			alert('还没有设置密码请先设置会员密码!');
			document.location.href="zhuce.html?OPENID="+openid;
			isok =false;
		}
		
		
	});
	return isok;
	
	
	
}
//支付取消按钮
$('#zhifu_dialog_cancel').click(function(e) {
	$('#zhifudialog_container').hide();
	
});




function zhifudialogshow(oid){
	if(!haspasswordornot()){
		return;
	};
	$('#zhifudialog_container').show();
	$('#password11').focus();
	$('#password11').trigger('focus');
	$('.myzhifumima').removeClass('myzhifumimatian');
	$('#password11').val('');
	$('#password11').off('keyup');
	$('#password11').on('keyup',function(){
		var aa=$(this).val();
		var len=aa.length;
		$('.myzhifumima').each(function(index, element) {
			if(index<len){
				$(this).addClass('myzhifumimatian');
			}else{
				$(this).removeClass('myzhifumimatian');
			}	
		});
		if(len==6){
			$('#password11').blur();
			checkmima(aa,oid);
		}
	});
	setTimeout(function(){
		$('#zhifu_dialog_body').css('margin-top',$('body').scrollTop()+10);
	},100);

}
$('.myzhifumima').click(function(e) {
	$('#password11').focus();
	setTimeout(function(){
		
		$('#zhifu_dialog_body').css('margin-top',$('body').scrollTop()+10);
	},100);
});

function checkmima(aa,oid){
	var url="/webserver/api/v1/user/?format=json&openid="+openid;
	$.getJSON(url,function(rs){
		$('#zhifudialog_container').hide();
		var object=rs.objects[0];
	
		var password=object.password;
		if(aa==password){
			
			payincash(oid);
		}else{
			toast('密码错误');
			
		}

	});

}
$('#zhifudialog_container').css('height',$(document).innerHeight());
*/
</script>
</body>
</html>